package com.example.demo.sf;

public class ListNode {

    int val;
    ListNode next;

    ListNode() {
    }

    ListNode(int val) {
        this.val = val;
    }

    ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    @Override
    public String toString() {
        //展示真个链表的数值
        StringBuilder sb = new StringBuilder();
        for (ListNode cur = this; cur != null; cur = cur.next) {
            sb.append(cur.val).append("->");
        }
        return sb.toString();
    }
}
